﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Practices.ServiceLocation;
using System.Windows.Input;

namespace VolunteerManager.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class GroupManagerViewModel : ViewModelBase
    {

        private ICommand _delCommand;        
        private ICommand _createCommand;

        /// <summary>
        /// Initializes a new instance of the GroupManagerViewModel class.
        /// </summary>
        public GroupManagerViewModel()
        {
        }

        #region    命令绑定
        public ICommand CreateCommand
        {
            get
            {
                if (null == _createCommand)
                {
                    _createCommand = new RelayCommand(() => create());
                }
                return _createCommand;
            }
        }

        private void create()
        {
            Model.Group g = new Model.Group();
            g.Name = "新建群";
            g.Save();
            
        }

        public ICommand DeleteCommand
        {
            get
            {
                if (null == _delCommand)
                {
                    _delCommand = new RelayCommand(() => delete(), () => canEdit());
                }
                return _delCommand;

            }
        }

        private bool canEdit()
        {
            throw new System.NotImplementedException();
        }

        private object delete()
        {
            throw new System.NotImplementedException();
        }
        #endregion

    }
}